package controller

import (
	"sale-admin/internal/app/web/service/robot"

	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type FaceCount struct{}

func (FaceCount) List(c *gin.Context) {
	var params struct {
		StartTime  int64     `json:"start_time"`
		EndTime    int64     `json:"end_time"`
		ShopID     *[]string `json:"shop_id"`
		ProvinceID string    `json:"province_id"`
		CityID     string    `json:"city_id"`
		DistrictID string    `json:"district_id"`
		LocationID string    `json:"location_id"`
		RobotID    string    `json:"robot_id"`
		Page       int       `json:"page"`
		Limit      int       `json:"limit"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	merchantID := c.GetString("merchant_id")
	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}
	list, total, summary, err := robot.FaceCount{}.List(c.Request.Context(), merchantID, shopIDList, params.RobotID,
		params.StartTime, params.EndTime, params.ProvinceID, params.CityID, params.DistrictID, params.LocationID,
		params.Page, params.Limit)
	response.JSON(c, gin.H{
		"summary": summary,
		"list":    list,
		"total":   total,
	}, err)
}
